package com.huazhi.wzsnw.service.impl;

import com.huazhi.wzsnw.mapper.RoleMapper;
import com.huazhi.wzsnw.model.Role;
import com.huazhi.wzsnw.model.User;
import com.huazhi.wzsnw.service.RoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public int save(Role record) {
        return roleMapper.insertSelective(record);
    }

    @Override
    public int delete(Role record) {
        return 0;
    }

    @Override
    public int deletes(List<Role> records) {
        return 0;
    }

    @Override
    public int update(Role record) {
        return roleMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    public Role findByTid(String tid) {
        return roleMapper.selectByPrimaryKey(tid);
    }

    @Override
    public List<Role> getRolesByUserTid(String usertid) {
        return roleMapper.selectRolesByUserTid(usertid);
    }

    @Override
    public List<Role> findPagingByListTid(List<String> stringList, Integer pageIndex, Integer pageSize) {
        return roleMapper.findPagingByListTid(stringList,pageIndex,pageSize);
    }

    @Override
    public List<String> getListTidBySearch(String search) {
        return roleMapper.selectListTidBySearch(search);
    }

    @Override
    public Role existsRole(String rolename) {
        return roleMapper.existsRole(rolename);
    }

    @Override
    public Role existsRoleTid(String tid, String rolename) {
        return roleMapper.existsRoleTid(tid,rolename);
    }

    @Override
    public List<User> getListUserByRoleTid(String roletid) {
        return roleMapper.selectListUserByRoleTid(roletid);
    }
}
